@ECHO OFF
set /p SQLSERVER= Give the SQL Server instance name?
set /p DATABASENAME= Give the DATABASE name?
set /p USERNAME= Give the user name?
set /p PWD= Give the password?
ECHO.
ECHO ********************************************
ECHO *******LOCAL DATABASE CREATION SCRIPT*******
ECHO ********************************************
ECHO.
ECHO Plese Wait ... [Finding Stored Procedures from all folders.]
@ECHO OFF
DIR ..\..\SqlServer*.* /S/B > AllStoredProcedureList.txt 
Pause

DEL StoredProcedure /Q
IF EXIST .\StoredProcedure RMDIR .\StoredProcedure /S/Q 
IF NOT EXIST .\StoredProcedure MKDIR .\StoredProcedure 
ECHO Plese Wait for couple of seconds ... [Creating local folder.]
Pause

FOR /F %%L IN (AllStoredProcedureList.txt) DO  (COPY %%L .\StoredProcedure /Y > NUL)
ECHO Plese Wait for couple of seconds ... [Copying all sql files.]
Pause

DEL .\StoredProcedure\OwnerProj.FeatureOrModule.TableOrBusinessdata.Operation.sql /Q 
ECHO Plese Wait for couple of seconds ... [Deleting unwanted sql files.]
pause

DIR .\StoredProcedure\*.* /S/B > AllStoredProcedureList.txt
DIR .\StoredProcedure\*.* /B 2>NUL
DIR .\StoredProcedure\*.* | Find "File(s)" 2>NUL
COPY /Y NUL TempDbAllStoredProcCreationScripts.SQLCMD > NUL
ECHO Plese Wait for couple of seconds ... [Collecting info for dynamic script file.]
pause

ECHO -- ============================================= >> TempDbAllStoredProcCreationScripts.SQLCMD
ECHO -- Script Template  >> TempDbAllStoredProcCreationScripts.SQLCMD
ECHO -- ============================================= >> TempDbAllStoredProcCreationScripts.SQLCMD
ECHO PRINT '** STARTING STORED PROCEDURE CREATION ...' >> TempDbAllStoredProcCreationScripts.SQLCMD
ECHO GO >> TempDbAllStoredProcCreationScripts.SQLCMD
ECHO :On ERROR EXIT >> TempDbAllStoredProcCreationScripts.SQLCMD
FOR /F %%L in (AllStoredProcedureList.txt) DO ECHO :r %%L >> TempDbAllStoredProcCreationScripts.SQLCMD
ECHO Plese Wait for couple of seconds ... [Creating dynamic script file.]
pause

ECHO PRINT '** STORED PROCEDURE CREATED SUCCESSFULLY' >> TempDbAllStoredProcCreationScripts.SQLCMD
ECHO GO >> TempDbAllStoredProcCreationScripts.SQLCMD
ECHO Plese Wait for couple of seconds ... [Dynamic script file created...]
PAUSE

ECHO.
SQLCMD -S %SQLSERVER% -U %USERNAME% -P %PWD% -d %DATABASENAME% -i DbAllTableCreationScriptForLocalDB.SQLCMD
PAUSE

ECHO.
SQLCMD -S %SQLSERVER% -U %USERNAME% -P %PWD% -d %DATABASENAME% -i TempDbAllStoredProcCreationScripts.SQLCMD
PAUSE

ECHO.
CD .\DefaultDataScripts > NUL
SQLCMD -S %SQLSERVER% -U %USERNAME% -P %PWD% -d %DATABASENAME% -i DbAllDefaultDataCreationScripts.SQLCMD
PAUSE

ECHO.
CD ..\ > NUL
ECHO Thank you ...
PAUSE
@ECHO ON